package com.qingyun.video.service.impl;



import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qingyun.model.video.pojos.Like;
import com.qingyun.video.mapper.LikeMapper;
import com.qingyun.video.service.LikeService;
import org.springframework.stereotype.Service;
import utils.thread.AppThreadLocalUtil;

@Service
public class LikeServiceImpl extends ServiceImpl<LikeMapper, Like> implements LikeService {
    @Override
    public Integer likeCount(Long videoId) {
        Integer count = query().eq("video_id", videoId).count();
        return count;
    }

    @Override
    public Boolean isLike(Long videoId) {
        if (AppThreadLocalUtil.getUser()==null)return false;
        Like one = query().eq("user_id", AppThreadLocalUtil.getUser().getId()).eq("video_id", videoId).one();

        return one!=null;
    }
}
